﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Default2 : System.Web.UI.Page 
{
    private SITUACAO objSituacao = new SITUACAO();
    private dbSisInfoDataContext Banco = new dbSisInfoDataContext();

    protected void Page_Load(object sender, EventArgs e)
    {
        Session["Titulo"] = "Página Inicial";
    }

    protected void btnIncluir_Click(object sender, EventArgs e)
    {
     
        objSituacao.Descricao = txtDescricao.Text;

        Banco.SITUACAOs.InsertOnSubmit(objSituacao);
        Banco.SubmitChanges();
        grdSituacoes.DataBind();

        txtDescricao.Text = string.Empty;
    }
    protected void grdSituacoes_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void btnPesquisar_Click(object sender, EventArgs e)
    {
        var busca = from b in Banco.SITUACAOs
                    where b.Descricao.Contains(txtDescricao.Text.ToString())
                    select b;
        grdSituacoes.DataSourceID = string.Empty;
        grdSituacoes.DataSource = busca;        
        
        grdSituacoes.DataBind();

    }
    protected void grdSituacoes_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        
    }
}
